package bj.gui

import scala.swing.event
import event.ButtonClicked
import scala.swing.Frame
import scala.swing.Label
import scala.swing.Swing
import scala.swing.Button
import scala.swing.FlowPanel
import scala.swing.BorderPanel
import javax.swing.ImageIcon

/** Pop up window showing the player's last ten moves in the game. This is not yet implemented */
class PlayerHistoryBox extends Frame {
  javax.swing.UIManager.setLookAndFeel(Constants.LF)
  println("Opened PlayerHistory Window")
  title = "Blackjack - Player History"
  minimumSize = Constants.historyBoxSize
  val titleLabel = new Label {
    text = "Scott" + "'s Betting History"
    border = Swing.EmptyBorder(10)
  }
  /* Player history for the last 10 games will be stored in Player. Player will have a method to return an array of Strings which will be used
   * to build historyLabel
   */
  val historyLabel = new Label {
    text = "<html>"
    text += "Betting History:<br><br>" 
    text += "</html>"
    border = Swing.EmptyBorder(10)
  }
  val okButton = new Button { text = "OK" }
  val buttonPanel = new FlowPanel() {
    contents += okButton
    background = Constants.greenBack
    border = Swing.EmptyBorder(10)
  }
  val historyPanel = new FlowPanel() {
    contents += historyLabel
    background = Constants.greenBack
  }
  val imagePanel = new FlowPanel() {
    contents += new Label {
      icon = new ImageIcon("images/BJLogo2.gif")
    }
    border = Swing.EmptyBorder(10)
    background = Constants.greenBack
  }
  contents = new BorderPanel() {
    add(imagePanel, BorderPanel.Position.North)
    add(historyPanel, BorderPanel.Position.Center)
    add(buttonPanel, BorderPanel.Position.South)
    background = Constants.greenBack
  }
  listenTo(okButton)
  reactions += {
    case ButtonClicked(okButton) => this.close();
  }
  visible = true
}